const appMenus = [
  {
    path: '/root',
    title: '梧桐前端',
    redirect: '',
    comPath: 'BasicLayout',
    menuType: '100',
    icon: '',
    children: [
      {
        path: '/basic',
        title: '基础组件',
        redirect: '',
        menuType: '100',
        comPath: 'ParentView',
        icon: '',
        children: [
          {
            path: '/basic/Button/index',
            title: '按钮',
            redirect: '',
            menuType: '100',
            icon: ''
          }
        ]
      },
      {
        path: '/animation',
        title: '动画组件',
        redirect: '',
        menuType: '100',
        comPath: 'ParentView',
        icon: '',
        children: [
          {
            path: '/animation/SlideWrap/index',
            title: '无限滑动',
            redirect: '',
            menuType: '100',
            icon: ''
          }
        ]
      }
    ]
  }
]

function treeForeach(tree, pid, func) {
  tree.forEach(data => {
    func(data, pid)
    data.children && treeForeach(data.children, data.id, func) // 遍历子树
  })
}

treeForeach(appMenus, 'root', (data, pid) => {
  data.id = data.path
  data.parentId = pid
  data.comPath = data.comPath || data.path
})
export default appMenus
